package cn.fsd.nacos;

import cn.fsd.domain.Order;
import cn.fsd.vo.ResultBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import static cn.fsd.util.FeignConstant.StoreRoomServiceUrl;

@Component
@FeignClient(value = "storeroom-server",url = StoreRoomServiceUrl)
public interface StoreRoomServer {
    @RequestMapping(value = "/storeroom/getMaxLimitation/{delivery_address}/{commodity_id}", method = RequestMethod.GET)
    Integer getMaxLimitation(@PathVariable String delivery_address, @PathVariable String commodity_id);

    /**
     * 检查订单是否缺货,需要调用dispatch微服务来请求中心库房id
     */
    @RequestMapping(value = "/storeroom/checkStockOut/{delivery_address}/{commodity_id}/{commodity_num}",method = RequestMethod.GET)
    Boolean checkStockOut(@PathVariable String delivery_address,@PathVariable String commodity_id,@PathVariable Integer commodity_num);

    /**
     * 检查订单是否缺货，通过中心库房id直接查询
     */
    @RequestMapping(value = "/storeroom/checkStockOutById/{storeroom_id}/{commodity_id}/{commodity_num}",method = RequestMethod.GET)
    Boolean checkStockOutByStoreroomId(@PathVariable String storeroom_id,@PathVariable String commodity_id,@PathVariable Integer commodity_num);
    /**
     * 当订单缺货时，操作仓库-订单表，修改缺货数量并将订单加入等待队列
     */
    @RequestMapping(value = "/storeroom/stockOutOP",method = RequestMethod.POST)
    ResultBean stockOutOP(@RequestBody Order order);

    /**
     * 订单状态为缺货或可分配时，退订该订单
     */
    @RequestMapping(value = "/storeroom/cancelOrder",method = RequestMethod.POST)
    ResultBean cancelOrder(@RequestBody Order order);



    @RequestMapping(value = "/storeroom/handle",method = RequestMethod.POST)
    ResultBean handle(@RequestBody Order order);
}



